package gof_003_行为型_Behavioral.gof_004_策略_Strategy.gof_001_Normal;

import java.util.ArrayList;
import java.util.List;

public class FilterStudent {

    //按照一定条件(年龄>20岁)过滤学生
    public List<Student> filter(List<Student> studentList) {
        //创建一个list集合用来保存过滤后的学生
        List<Student> list = new ArrayList<>();

        //遍历学生列表
        for (int i = 0; i < studentList.size(); i++) {
            Student student = studentList.get(i);

            //如果学生的年龄大于 20 岁
            if (student.getAge() > 20) {
                list.add(student);
            }
        }
        return list;
    }

}
